/**
 * lib/get-query
 *
 * 简单实现，未完善
 *
 */

const rreEscape = /[-/\\^$*+?.()|[\]{}]/g;

module.exports = function(key, queryString = location.search) {
    const re = new RegExp('(?:^|\\?|\\&)' + key.replace(rreEscape, '\\$&') + '=([^&]+)');
    const val = re.test(queryString) ? RegExp.$1 : '';

    return decodeURIComponent(val);
};
